home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dirut / nfd104.zip / NFD.ASM < prev    next >
Assembly Source File  |  1987-11-25  |  30KB  |  667 lines

  1.         TITLE   NFD - New File Date Utility 1.03 28 Oct 87
  2.     page    62,132
  3.  
  4. ;*************************************************************************
  5. ; This program is NOT copyrighted in any way and may be used in whole or
  6. ; in part in any manner.  The author, as is usual, makes no claims about
  7. ; the suitability of this program for any purpose whatsoever and disclaims
  8. ; liability for any damages, actual or consequential, that may arise from
  9. ; use of this program.
  10. ;
  11. ;     Don A. Williams
  12. ;     7 Mar 86
  13. ;*************************************************************************
  14.  
  15. ;*************************************************************************
  16. ; The source for NFD, NFD.ASM, as issued is intended for use with
  17. ; SpeedWare's excellent assembler, Turbo Editasm.  For use with Micrsoft's
  18. ; MASM, SEGMENT, ASSUME, and ENDS statements will have to be added.
  19. ;*************************************************************************
  20.  
  21. ;*************************************************************************
  22. ; Source modified on 28 Oct 87 for use with MASM and added a conditional
  23. ; to GetArgs in order to allow the "Usage: . . ." output when no arguments
  24. ; are supplied.  (Aside:  the differences in the generated machine code,
  25. ; MASM vs. Turbo Editasm, are interesting to say the least.  CISC cause
  26. ; no doubt.) -- Will Jordan
  27. ; Source modified again 25 Nov 87 -- flipped condition (jnz, was jz) 2
  28. ; lines before "GotDir:"; corrected "Could not find file" message when
  29. ; the filename is explicitly entered.
  30. ;*************************************************************************
  31.  
  32. CODESEG  segment para public 'code'
  33.          assume cs:CODESEG,ds:CODESEG,es:CODESEG,ss:CODESEG
  34.  
  35. LF      EQU     0AH
  36. CR      EQU     0DH
  37.  
  38. DTA    EQU    80H            ; define (default) DTA of PSP
  39. FATTRD  EQU    byte ptr DTA[21]    ; defining all parm's, even not used
  40. FTIMED    EQU    word ptr DTA[22]
  41. FDATED    EQU    word ptr DTA[24]
  42. FSIZLD    EQU    word ptr DTA[26]
  43. FSIZHD    EQU    word ptr DTA[28]
  44. FNAMED    EQU    byte ptr DTA[30]
  45.  
  46. ARDONLY    EQU    01H            ; define file attribute (FATTR) bits
  47. AHIDDEN    EQU    02H
  48. ASYSTEM    EQU    04H
  49. AVOLLAB    EQU    08H
  50. ASUBDIR    EQU    10H
  51. AARCHIV    EQU    20H
  52.  
  53.         ORG     0100H
  54.  
  55. Start:  jmp     Begin
  56.  
  57. DateSw  dw      0
  58. TimeSw  dw      0
  59.  
  60. NFDate  dw      0                       ; New Date for file
  61. NFTime  dw      0                       ; New Time for file
  62.  
  63. FDate   dw      0                       ; File Date From/To Function 57H
  64. FTime   dw      0                       ; File Time From/To Function 57H
  65.  
  66. Hour    dw      0
  67. Minute  dw      0
  68. Second  dw      0
  69.  
  70. Day     dw      0
  71. Month   dw      0
  72. Year    dw      0
  73.  
  74. ArgSep  db      0
  75.  
  76. TmpCnt  dw      0
  77. PtrOfs  dw      0
  78.  
  79. UseMsg  db      'Usage is: NFD <filename> [mm/dd/yy] [hh:mm:ss]',CR,LF
  80.     db    '  /s for silent operation (no STDOUT)',CR,LF
  81.     db    '  /n for no query',CR,LF,'$'
  82.  
  83. NFMsg   db      'Could not find file',CR,LF,'$'
  84.  
  85. BDMsg   db      'Incorrect date',2CH,' format is mm/dd/yy or mm-dd-yy',CR,LF,'$'
  86.  
  87. BTMsg   db      'Incorrect time',2CH,' format is hh:mm:ss',CR,LF,'$'
  88.  
  89. IntMsg  db      'Internal error during file access',CR,LF,'$'
  90.  
  91. SignOn    db    'NFD Version: 1.04  -  25 Nov 87',CR,LF,LF,0
  92.  
  93. From    db      CR,LF,'    From: ',0
  94.  
  95. To      db      '   To: ',0
  96.  
  97. CrLfMs  db      CR,LF,0
  98.  
  99. Query   db      '   Change? ',0
  100.  
  101. Begin:  mov    SI,offset SignOn    ; Display logon message
  102.     call    PrtStr            ; ...
  103.     call    GetArgs                 ; Parse Command Line arguments
  104.         cmp     word ptr ARGC,0         ; Check for no arguments
  105.         jz      Usage                   ; ... Xfr - no arguments
  106.         cmp     word ptr ARGC,4         ; Check for more than 4 arguments
  107.         ja      Usage                   ; ... Xfr - more than 4
  108.         call    GetPath                 ; Extract Path from File Path Name
  109.     call    DateTime
  110.     cmp    word ptr DateSw,0    ; Check for Date argument
  111.     jne    CheckTime        ; ... Xfr - Date on Command Line
  112.         mov     AH,2AH                  ; MS-DOS 'Get Date'
  113.         int     21H                     ; ... DOS Entry Interrupt
  114.         sub     CX,1900                 ; Make Year 1900 relative
  115.         mov     Year,CX                 ; ... and save it
  116.         mov     CL,DH                   ; Move Month to CX as 16-bit value
  117.         mov     CH,0                    ; ...
  118.         mov     Month,CX                ; ... and save it
  119.         mov     CL,DL                   ; Move Day to CX as 16-bit value
  120.         mov     Day,CX                  ; ... and save it
  121. CheckTime:
  122.     cmp    word ptr TimeSw,0    ; Check for Time on Command Line
  123.     jne    Here            ; ... Xfr - Time on Command Line
  124.         mov     AH,2CH                  ; MS-DOS 'Get Time'
  125.         int     21H                     ; ... DOS Entry Interrupt
  126.         mov     AX,0                    ; Move Hour to AX as 16-bit value
  127.         mov     AL,CH                   ; ...
  128.         mov     Hour,AX                 ; ... and save it
  129.         mov     AL,CL                   ; Move Minute to AX as 16-bit value
  130.         mov     Minute,AX               ; ... and save it
  131.         mov     AL,DH                   ; Move Second to AX as 16-bit value
  132.         mov     Second,AX               ; ... and save it
  133.     mov    word ptr DateSw,0FFH
  134.     mov    word ptr TimeSw,0FFH
  135. Here:   jmp     Format
  136.  
  137. Usage:  mov     DX,offset UseMsg        ; Display 'Usage' message
  138.         mov     AH,9                    ; ... MS-DOS 'Print String'
  139.         int     21H                     ; ... DOS Entry Interrupt
  140.         mov     AL,1                    ; Set error code
  141.         jmp     Term                    ; ... and terminate
  142.  
  143. DateTime:
  144.         mov     AX,ARGC                 ; Initialize loop counter to ARGC
  145.         mov     TmpCnt,AX               ; ...
  146.         mov     word ptr PtrOfs,0       ; Initialize Arg ptr offset to 0
  147.  
  148. ArgLoop:
  149.         add     word ptr PtrOfs,2       ; Incr Arg ptr offset
  150.         dec     word ptr TmpCnt         ; ... and decr loop count
  151.         jnz     DoArg                   ; ... Xfr - loop count not exhausted
  152.     ret
  153.  
  154. DoArg:
  155.         mov     BX,PtrOfs               ; Get Arg ptr offset
  156.         mov     SI,[BX+ARGV]            ; ... and Arg ptr
  157.         mov     AL,byte ptr [SI]        ; Check for switch arg
  158.         cmp     AL,'/'                  ; ... primary switch char
  159.         je      Switch                  ; ... Xfr - got switch
  160.         cmp     AL,'-'                  ; ... secondary switch char
  161.         je      Switch                  ; ... Xfr - got switch
  162.         call    GetNumber               ; Convert 1st arg field to binary
  163.         cmp     AL,'/'                  ; Check for Date field separator
  164.         jz      GotMonth                ; ... Xfr - got separator
  165.         cmp     AL,'-'                  ; Check for Date field separator
  166.         jz      GotMonth                ; ... Xfr - got separator
  167.         cmp     AL,':'                  ; Check for Time field spearator
  168.         jnz     Usage                   ; ... Xfr - bad format
  169.         jmp     GotHour                 ; Xfr - got separator
  170.  
  171. Switch:
  172.         inc     SI                      ; Skip switch char
  173.  
  174. SWLoop: lodsb                           ; Get byte
  175.         cmp     AL,0                    ; Check for NULL terminator
  176.         je      ESW                     ; ... Xfr - NULL - end of Arg
  177.         and     AL,0DFH                 ; Force upper case
  178.         cmp     AL,'N'                  ; Check for 'No Query'
  179.         je      NQ                      ; ... Xfr - 'No Query
  180.         cmp     AL,'S'                  ; Check for 'Silent'
  181.         je      Silent                  ; ... Xfr - 'Silent'
  182.         jmp     Usage                   ; Xfr - invalid switch
  183.  
  184. NQ:     mov     byte ptr QSwt,0FFH      ; Turn on No Query Switch
  185.         jmp     short SWLoop            ; Go try for another switch
  186.  
  187. Silent: mov     byte ptr SSwt,0FFH      ; Turn on Silent Switch
  188.         jmp     short SWLoop            ; Go try for another switch
  189.  
  190. ESW:    jmp    ArgLoop         ; Go try for another argument
  191.  
  192.  
  193. ErExit: mov     AH,9                    ; MS-DOS 'Print String'
  194.         int     21H                     ; ... DOS Entry Interrupt
  195.         mov     AL,2
  196.